﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DrugStorehouseMIS.Comm;
using DrugStorehouseMIS.DAL;

namespace DrugStorehouseMIS.BLL
{
    public class Manager
    {
        private StockInHeader Inheader;
        private StockInDetail Indetail;

        private StockOutHeader OutHeader;
        private StockOutDetail OutDetail;

        private Inventory inventory;
        private IList<StockInDetail> Inlist;
        private IList<StockOutDetail> Outlist;

        public  Manager()
        {
            Inheader = new StockInHeader();
            Inheader.StockInTypeName = new StockInType();
            Inheader.SupplierName = new Supplier();

            Indetail = new StockInDetail();
            Indetail.DrugNum = new Drug();

            OutHeader = new StockOutHeader();
            OutHeader.StockOutTypeName = new StockOutType();
            OutHeader.DepartmentName = new Department();

            OutDetail = new StockOutDetail();
            OutDetail.DrugNum = new Drug();

            inventory = new Inventory();
            inventory.DrugNum = new Drug();
        }


        public void ConfirmStockIn(StockInHeader Header,IList<StockInDetail> DetailList)
        {
            this.Inheader = Header;
            this.Inlist = DetailList;

            foreach (StockInDetail obj in Inlist)
            {
                Inventory  test = new Inventory();
                test.DrugNum = new Drug();

                test.DrugNum.DrugNum = obj.DrugNum.DrugNum;
                test.StockQuantity = obj.Quantity;

                inventory.AddInventory(test);

               

                //foreach (int num in test.StockQuantity)
                //{

                //}

               // Inventory inven = new Inventory();
               // inven.DrugName = new Drug();

               // inven.BatchNum = obj.BatchNum;
               //// inven.DrugName.TradeName = obj.DrugName.TradeName;
               // inven.ExpiryDatetime = obj.ExpiryDatetime;
               // inven.ImportPrice = obj.ImportPrice;
      
               // inven.StockInDatetime = header.StockInDatetime;
               // inven.StockInNum = obj.StockInNum;
               // inven.StockQuantity = obj.Quantity;

               // inventory.Insert(inven);
            }

        }

        public void ConfirmStockOut(StockOutHeader Header, IList<StockOutDetail> DetailList)
        {
            this.OutHeader = Header;
            this.Outlist = DetailList;

            foreach (StockOutDetail obj in Outlist)
            {
                Inventory test = new Inventory();
                test.DrugNum = new Drug();

                test.DrugNum.DrugNum = obj.DrugNum.DrugNum;
                test.StockQuantity = obj.RealQuantity;

                inventory.CutInventory(test);

            }
        }

    }
}
